package model.metrics
{
	import visualization.IDataPoint;
	
	public class Average extends Metric
	{
		public function Average()
		{
			super();
			this.title = "Average";
		}
		
		private var _sum:Number = 0;
		private var _count:Number = 0;
		override public function startMetric( arr:Array ):void{
			this._sum = 0;
			this._count = 0;
		}
		
		override public function iterate(item:IDataPoint):void{
			this._sum += item.getData(this.field) as Number;
			this._count++;
		}
		
		override public function finishMetric(arr:Array):Object{
			return this._sum/this._count;
		}
		
	}
}